/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package exercicio14;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Caio
 */
public class CustomersData extends DataObject {

    private List<String> _customers = new ArrayList<String>();
    private int _current = 0;

    public CustomersData() {
        // Loaded from a database
        _customers.add("Jim Jones");
        _customers.add("Samual Jackson");
        _customers.add("Allen Good");
        _customers.add("Ann Stills");
        _customers.add("Lisa Giolani");
    }

    @Override
    public void NextRecord() {
      
         if (_current <= _customers.size()-1)
      {
        _current++;
      }
        
        
    }

    @Override
    public void PriorRecord() {
        if (_current > 0)
      {
        _current--;
      }
        
    }

    @Override
    public void AddRecord(String customer) {
        
         _customers.add(customer);
        
    }

    @Override
    public void DeleteRecord(String customer) {
       _customers.remove(customer);
    }

    @Override
    public void ShowRecord() {
         System.out.println(_customers.get(_current));
    }

    @Override
    public void ShowAllRecords() {
        for (Iterator<String> it = _customers.iterator(); it.hasNext();) {
            String string = it.next();
            System.out.println(" "+string);
        }
    }

}
